<%@page import="java.util.List"%>
<%@page import="cn.school.mybaits.Dao.GradeDao"%>
<%@page import="cn.school.mybaits.entity.Grade"%>
<%@page import="cn.school.mybaits.xml.MyBatisUtil"%>
<%@page import="org.apache.ibatis.session.SqlSession"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%!public static List<Grade> search() {
		SqlSession session = MyBatisUtil.get();// 连接
		GradeDao gradeDao = session.getMapper(GradeDao.class);
		List<Grade> list = gradeDao.search();
		MyBatisUtil.close(session);
		return list;
	}%>
	<%
		out.print("<table border='1' align='center' cellpadding='0' cellspacing='0'>");
		out.print("<tr><th>id</th><th>gname</th></tr>");
		List<Grade> li = search();
		for (Grade g : li) {
			out.print("<tr><td>" + g.getId() + "</td><td>" + g.getGname() + "</td></tr>");
		}
		out.print("</table>");
	%>

</body>
</html>